import turtle
turtle.penup()

turtle.goto((-250,250))
turtle.setup(1024,1024)
turtle.pendown()
turtle.speed(10)
size = 512
n = 28

def koch(size,n):
    if n == 0:
        for j in range(1,size + 1):
            turtle.forward(1)
            turtle.color((j/size,j/size,j/size))
    else:
        for i in [0,60,-120,60]:
            turtle.left(i)
            koch(size // 3,n - 1)
            
for i in range(0,3):    
    koch(size,n)
    turtle.right(120)